﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace SharePointLogBrowser2
{
    public partial class TextFilters : UserControl
    {
        public TextFilters()
        {
            InitializeComponent();
        }

        private void btnLoad_Click(object sender, EventArgs e)
        {
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                LogItemContext.Current.LoadTextFilters(ofd.FileName);
                SetTextFilterView();
            }
        }

        private void g_Click(object sender, EventArgs e)
        {
            if (sfd.ShowDialog() == DialogResult.OK)
            {
                LogItemContext.Current.SaveTextFilters(sfd.FileName);
            }
        }

        private void SetTextFilterView()
        {
            lvTextFilter.BeginUpdate();
            lvTextFilter.Items.Clear();
            foreach (FilterItem filter in LogItemContext.Current.TextFilters)
            {
                ListViewItem lvi = new ListViewItem(filter.Text);

                lvTextFilter.Items.Add(lvi);
            }
            lvTextFilter.EndUpdate();
        }

        private void btnClear_Click(object sender, EventArgs e)
        {
            LogItemContext.Current.TextFilters.Clear();

            lvTextFilter.Items.Clear();
        }
    }
}
